Type.registerNamespace("Telerik.Web.UI.Scheduler");
(function(b,c,d){var i=60000;
var e=i*60;
var g=e*24;
var a=8*e;
var f=18*e;
var h=4;
c.Scheduler.WeekModelBase=function(j){this._owner=j;
this._settings=this._owner.get_weekViewSettings();
this._defaultHeaderDateFormat="d";
this._defaultColumnHeaderDateFormat="ddd, d";
};
c.Scheduler.WeekModelBase.prototype={get_visibleRangeStart:function(){var j=this._owner;
var k=d.DateHelper.getStartOfWeek(j.get_selectedDate(),j.get_firstDayOfWeek());
if(!j.get_showAllDayRow()){k=d.DateTime.add(k,this.get_effectiveDayStartTime());
}return k;
},get_visibleRangeEnd:function(){var j=this._owner;
var k=d.DateHelper.getEndOfWeek(j.get_selectedDate(),j.get_firstDayOfWeek(),this.get_numberOfDays()-1);
if(!j.get_showAllDayRow()){k=d.DateTime.add(k,this.get_effectiveDayEndTime());
}else{k=d.DateTime.add(k,g);
}return k;
},get_numberOfDays:function(){var j=this._owner;
return d.DateHelper.getWeekLength(j.get_selectedDate(),j.get_firstDayOfWeek(),j.get_lastDayOfWeek());
},get_dayStartTime:function(){if(!this._settings){return a;
}return this._settings.dayStartTime||a;
},get_dayEndTime:function(){if(!this._settings){return f;
}return this._settings.dayEndTime||f;
},get_effectiveDayStartTime:function(){return this._owner.get_showFullTime()?0:this.get_dayStartTime();
},get_effectiveDayEndTime:function(){var j=this._owner.get_showFullTime()?g:this.get_dayEndTime();
var n=j-this.get_effectiveDayStartTime();
var l=n/i;
var m=this._owner.get_minutesPerRow();
var k=Math.round(Math.ceil(l/m));
return this.get_effectiveDayStartTime()+(k*m*i);
},get_slotsPerDay:function(){var j=(this.get_effectiveDayEndTime()-this.get_effectiveDayStartTime())/i;
return j/this._owner.get_minutesPerRow();
},get_nextPeriodDate:function(){return d.DateTime.add(this._owner.get_selectedDate(),(7*g));
},get_previousPeriodDate:function(){return d.DateTime.add(this._owner.get_selectedDate(),-(7*g));
},get_headerDateFormat:function(){if(!this._settings){return this._defaultHeaderDateFormat;
}return this._settings.headerDateFormat||this._defaultHeaderDateFormat;
},get_columnHeaderDateFormat:function(){if(!this._settings){return this._defaultColumnHeaderDateFormat;
}return this._settings.columnHeaderDateFormat||this._defaultColumnHeaderDateFormat;
},updateResizingAppointmentSize:function(j,o){var m=j.parentNode.parentNode;
var l=m.offsetHeight;
var n=o.parentNode.rowIndex-m.parentNode.rowIndex;
n=Math.min(n,this._getMaxAppointmentGrowth(m));
var p=Math.max(1,(n+1))*l;
var k=parseInt(j.style.paddingBottom);
k=isNaN(k)?0:k;
p-=k;
if($telerik.isIE&&$telerik.quirksMode){p-=$telerik.getBorderBox(m).vertical*2;
}p-=h;
j.style.height=p+"px";
b(".rsAptOut, .rsAptMid, .rsAptIn, .rsAptContent",j).css("height",p+"px");
},isVisible:function(j){return this._isInsideVisibleRange(j);
},_isInsideVisibleRange:function(j){var o=d.DateTime.getDate(this.get_visibleRangeStart());
for(var m=0,l=this.get_numberOfDays();
m<l;
m++){var k=d.DateTime.add(o,g*m);
var n=d.DateTime.add(k,this.get_effectiveDayEndTime());
k=d.DateTime.add(k,this.get_effectiveDayStartTime());
if(j._isInRange(k,n)){return true;
}}return false;
},_getFirstDayStart:function(){var j=d.DateHelper.getStartOfWeek(this._owner.get_selectedDate(),this._owner.get_firstDayOfWeek());
return new d.DateTime(d.DateTime.getDate(j)).add(this.get_effectiveDayStartTime()).toDate();
},getDurationOfMovedAppointment:function(j,l,k){var o=k.get_isAllDay();
var n=l.get_isAllDay();
var m=j.get_duration();
if(o&&!n){m=k.get_duration();
}if(n&&!o){m=this._owner.get_minutesPerRow()*this._owner.get_numberOfHoveredRows()*i;
}return m;
},_getMaxAppointmentGrowth:function(j){return j.parentNode.parentNode.rows.length;
},getDurationOfInsertedAppointment:function(j){if(j.get_isAllDay()){return j.get_duration();
}else{return j.get_duration()*this._owner.get_numberOfHoveredRows();
}}};
c.Scheduler.WeekModelBase.registerClass("Telerik.Web.UI.Scheduler.WeekModelBase",null,c.ISchedulerModel);
c.Scheduler.WeekModel=function(j){c.Scheduler.WeekModel.initializeBase(this,[j]);
if(d.Rendering.BlockCollection){this._blockCollection=new d.Rendering.BlockCollection();
}if(d.Rendering.HorizontalBlockCollection){this._allDayBlocks=new d.Rendering.HorizontalBlockCollection();
}};
c.Scheduler.WeekModel.prototype={initialize:function(){},getTimeSlotFromDomElement:function(l){var m=60*24;
var k=this._getRawIndexFromDomElement(l);
var j=this._getTimeFromDomElement(l);
var n=(k.viewPartIndex==0)?m:this._owner.get_minutesPerRow();
return new c.Scheduler.WeekTimeSlot(k,j,n,l);
},_getTimeFromDomElement:function(j){var k=this._getRawIndexFromDomElement(j);
return this._getTimeFromIndex(k);
},_getTimeFromIndex:function(l){var j;
if(l.viewPartIndex==0){j=d.DateHelper.getStartOfWeek(this._owner.get_selectedDate(),this._owner.get_firstDayOfWeek());
}else{j=this._getFirstDayStart();
}var k=l.rowIndex*this._owner.get_minutesPerRow();
return new d.DateTime(j).add(l.cellIndex*g).add(k*i).toDate();
},_getRawIndexFromDomElement:function(k){while(k&&k.tagName.toUpperCase()!="TD"&&k.tagName.toUpperCase()!="TH"){k=k.parentNode;
}if(k){var o=k.cellIndex;
var n=k.parentNode.rowIndex;
var j=k.parentNode;
var m=Sys.UI.DomElement.containsCssClass(j,"rsAllDayRow");
var l=m?0:1;
return{cellIndex:o,rowIndex:n,viewPartIndex:l};
}return null;
},getTimeSlotForAppointment:function(j){var m=j._isAllDay()&&this._owner.get_showAllDayRow();
var l=m?0:1;
var n;
if(m){n=this._getAllDayTimeSlotIndices(j.get_start());
}else{n=this._getRegularTimeSlotIndices(j.get_start());
}n.viewPartIndex=l;
var o=this._getTimeSlotDomElement(l,n.rowIndex,n.cellIndex);
var k=this._getTimeFromIndex(n);
return this._createTimeSlot(n,k,o);
},_createTimeSlot:function(k,j,l){var m=60*24;
var n=(k.viewPartIndex==0)?m:this._owner.get_minutesPerRow();
return new c.Scheduler.WeekTimeSlot(k,j,n,l);
},_getAllDayTimeSlotIndices:function(l){var k=this.get_visibleRangeStart();
var m=new d.DateTime(l).subtract(k);
var n=Math.max(0,Math.round(m/g));
var j=0;
return{rowIndex:j,cellIndex:n};
},_getAllDayTimeSlotForAppointmentPart:function(l){var j=this._getAllDayTimeSlotIndices(l.start);
j.viewPartIndex=0;
var k=this._getTimeSlotDomElement(j.viewPartIndex,j.rowIndex,j.cellIndex);
return this._createTimeSlot(j,l.start,k);
},_getTimeSlotForAppointmentPart:function(m){var k=m.start;
var j=this._getRegularTimeSlotIndices(k);
var l=this._getTimeSlotDomElement(1,j.rowIndex,j.cellIndex);
return this._createTimeSlot(j,k,l);
},_getRegularTimeSlotIndices:function(l){var k=this._getFirstDayStart();
var n=new d.DateTime(l).subtract(k);
var o=Math.max(0,Math.floor(n/g));
var m=n-(o*g);
var j=Math.max(0,Math.floor(m/(this._owner.get_minutesPerRow()*i)));
return{rowIndex:j,cellIndex:o};
},_getTimeSlotDomElement:function(j,l,m){var k=this._owner.get_element();
if(j==0){return b("div.rsTopWrap .rsAllDayRow",k).children()[m];
}return b("div.rsTopWrap table.rsContentTable",k)[0].tBodies[0].rows[l].cells[m];
},removeFromBlock:function(j){this._allDayBlocks.remove(j);
this._blockCollection.remove(j);
},addToBlocks:function(j){if(j.isAllDay){this._allDayBlocks.add(j);
}else{this._blockCollection.add(j);
}},_getRenderer:function(){if(!this._renderer){this._renderer=new c.Scheduler.Rendering.WeekViewRenderer(this);
}return this._renderer;
}};
c.Scheduler.WeekModel.registerClass("Telerik.Web.UI.Scheduler.WeekModel",c.Scheduler.WeekModelBase);
c.Scheduler.WeekTimeSlot=function(k,j,m,l){this._rawIndex=k;
this._startTime=j;
this._durationInMinutes=m;
this._domElement=l;
};
c.Scheduler.WeekTimeSlot.prototype={get_index:function(){var j=this.get_rawIndex();
return String.format("{0}:{1}:{2}",j.viewPartIndex,j.rowIndex,j.cellIndex);
},get_rawIndex:function(){return this._rawIndex;
},get_startTime:function(){return this._startTime;
},get_endTime:function(){return d.DateTime.add(this.get_startTime(),this.get_duration());
},get_duration:function(){return this.get_durationInMinutes()*i;
},get_durationInMinutes:function(){return this._durationInMinutes;
},get_isAllDay:function(){return this.get_rawIndex().viewPartIndex==0;
},get_domElement:function(){return this._domElement;
}};
c.Scheduler.WeekTimeSlot.registerClass("Telerik.Web.UI.Scheduler.WeekTimeSlot",null,c.ISchedulerTimeSlot);
})($telerik.$,Telerik.Web.UI,Telerik.Web.UI.Scheduler);
